package com.ruoyi.web.controller.system;

import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;

public class RequestTask implements Callable<HttpResponse<String>> {
    private final List<String> params;

    public RequestTask(List<String> params) {
        this.params = params;
    }

    @Override
    public HttpResponse<String> call() throws Exception {
        String requestParameter = params.stream().collect(Collectors.joining(","));
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder().uri(URI.create("https://qt.gtimg.cn/q=" + requestParameter)).build();
        HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
        return httpResponse;
    }

}
